< previous page page_638 next page >

Page 638
e10a6a0a59f035e870d90cca05b85fce.gif
' Randomize the normal a little bit and
' renormalize.
Nx = Nx + Rnd * Bumpiness
Ny = Ny + Rnd * Bumpiness
Nz = Nz + Rnd * Bumpiness
n_len = Sqr(Nx * Nx + Ny * Ny + Nz * Nz)
Nx = Nx / n_len 
Ny = Ny / n_len 
Nz = Nz / n_len
The result is a surface that looks more like the textured plastic and metal commonly used to make computers than the perfectly smooth objects produced by the standard shading model. Figure 17.31 shows a sphere produced with this technique.
This simple method has a couple of drawbacks. First, each pixel is randomized independently. That gives the surface a texture on a very fine scale. Many real surfaces are more similar to the fractal surfaces described in Chapter 14, Surfaces. They have big bumps that contain smaller bumps that contain smaller bumps. The technique demonstrated by the RayBumpySphere class produces very small bumps of perfectly even size.
Another drawback to this method is that it randomizes the surface normals randomly. In other words, if you generate the same image again from a slightly different viewpoint or from a slightly different distance, all the normals are perturbed in a different way. If you generate only individual images, that is not a problem. If you try to run them together as an animation, however, the texture on the surface moves around. The image seems to sparkle. To prevent this, the surface needs to generate the same random perturbations for a particular point on the surface, no matter how it is viewed.
Environment Mapping
Environment mapping takes an image and maps it onto a surface. You can use some of the same techniques described in Chapter 7, Area Processes, to map pixels from the
0638-01.jpg
Figure 17.31
A bumpy sphere produced by normal vector perturbation.

 
< previous page page_638 next page >